<?php
$oClients = ClientHandler::getClients();
$oClientgroups = ClientHandler::getClientgroups();
$oTimes = TimeHandler::getTimes($_SESSION['rid'], $_REQUEST['iMonth'], $_REQUEST['iYear']);
?>
<div class="hidden" id="layer_time_change" style="visibility: visible;">
<form action="index.php" method="post" name="form_time_change">
<input type="hidden" name="sAction" value="time-change">
<input type="hidden" name="sView" value="<?php print $_REQUEST['sView'] ?>">
<input type="hidden" name="iMission" value="<?php print $_REQUEST['iMission'] ?>">
<input type="hidden" name="iTime" value="<?php print $_REQUEST['iTime'] ?>">
<input type="hidden" name="iYear" value="<?php print $_REQUEST['iYear'] ?>">
<input type="hidden" name="iMonth" value="<?php print $_REQUEST['iMonth'] ?>">
<table class="boxborder" cellspacing="0">
	<tr>
		<td class="boxhandle" colspan="2"><?php print msg('Change time') ?></td>
	</tr>
	<tr>
		<td class="fieldname"><?php print msg('Description') ?>:</td>
		<td class="fieldvalue"><input type="text" name="sDescription" value="<?php print htmlspecialchars(stripslashes($oTimes[$_REQUEST['iTime']]->sDescription)) ?>"></td>
	</tr>
	<tr>
		<td class="fieldname"><?php print msg('Date') ?>:</td>
		<td class="fieldvalue">
			<input type="text" name="iYear" size="4" value="<?php print date('Y', $oTimes[$_REQUEST['iTime']]->iStartTime) ?>">-<input type="text" name="iMonth" size="2" value="<?php print date('m', $oTimes[$_REQUEST['iTime']]->iStartTime) ?>">-<input type="text" name="iDay" size="2" value="<?php print date('d', $oTimes[$_REQUEST['iTime']]->iStartTime) ?>">
		</td>
	</tr>
	<tr>
		<td class="fieldname"><?php print msg('Times') ?>:</td>
		<td class="fieldvalue"><input type="text" name="iHours" size="5" value="<?php print ($oTimes[$_REQUEST['iTime']]->iDuration / 60 / 60) ?>"></td>
	</tr>
	<tr>
		<td class="fieldname"><?php print msg('Client') ?>:</td>
		<td class="fieldvalue">
			<select name="sSerial">
				<option class="listentity" value="0">[ <?php print msg('None') ?> ]</option>
<?php
foreach ($oClientgroups as $oThisClientgroup)
{
	$bShown = false;
	foreach ($oClients as $oThisClient)
	{
		if ($oThisClient->iGroup == $oThisClientgroup->iID)
		{
			if (!$bShown)
			{
				echo '<option class="separator">'.$oThisClientgroup->sName.'</option>';
				$bShown = true;
			}
			echo '<option class="listentity" value="'.$oThisClient->sSerial.'" '.($oThisClient->sSerial == $oTimes[$_REQUEST['iTime']]->sSerial ? 'selected' : '').'>'.$oThisClient->sName.'</option>';
		}
	}
}
?>
			</select>
		</td>
	</tr>
	<tr>
		<td class="boxbody small center" colspan="2">
			<input type="checkbox" name="bOvertime" value="1" onClick="document.form_time_change.bDriving.checked = false;" <?php print ($oTimes[$_REQUEST['iTime']]->bOvertime ? 'checked' : '') ?>> <?php print msg('Overtime') ?>
			&nbsp;&nbsp;
			<input type="checkbox" name="bDriving" value="1" onClick="document.form_time_change.bOvertime.checked = false;" <?php print ($oTimes[$_REQUEST['iTime']]->bDriving ? 'checked' : '') ?>> <?php print msg('Driving') ?>
		</td>
	</tr>
	<tr>
		<td class="boxbody center" colspan="2">
			<input type="submit" value="<?php print msg('OK') ?>">
			<input type="button" value="<?php print msg('Cancel') ?>" onClick="layerHide('layer_time_change');">
		</td>
	</tr>
</table>
</form>
</div>

